^ What's the point?
^ AlphaIcon
^ LineHQ
^ BackendRelease
^ MemoryBackendNoInit
^ MemoryBackend Transparent
^ PNGImage2Bitmap32
^ Resampler
^ Shadow
^ ShellItemImageFactory
^ TBitmap
^ VideoFilmStrip

Top
Delphi Graphics32 3delite Helpers

Delphi Graphics32 components to speed-up things and provide some useful utility functions.
Fast and thread-safe.
  • GR32_AlphaBlit: Draw a TBitmap32 transparently on a canves.
  • GR32_AlphaIcon: Convert (assign) a HIcon handle or a TIcon to a TBitmap32 with full transparency support.
  • GR32_BackendRelease: Allows assigning a GR32 TBitmap32 to a Windows GDI TBitmap with one line of code that avoids copying the bitmap.
  • GR32_LineHQ: Drawing high quality antialiased lines with one line of code on a TBitmap32 canvas.
  • GR32_MemoryBackendNoInit: When resizing a GR32 TBitmap32 to a new size the bitmap buffer is not initialized at all.
  • GR32_MemoryBackendTransparent: When resizing a GR32 TBitmap32 to a new size the bitmap is initialized to a transparent background.
  • GR32_PNGImage2Bitmap32: Convert a TPNGImage to TBitmap32 and vice versa with full transparency support.
  • GR32_Resampler: Resize a TBitmap32 or a TBitmap with one line of code with Graphics32's high quality resamplers.
  • GR32_Rotate: Rotate a TBitmap32 by any angle with transparency support.
  • GR32_SetResampler: Set a kernel resampler for a TBitmap32 with one line of code.
  • GR32_Shadow: Add a shadow effect to a TBitmap32 or TBitmap with one line of code. Typically to be used for thumbnails.
  • GR32_ShellItemImageFactory: Get the shell image of a file or folder to a TBitmap32 with one line of code with full transparency support.
  • GR32_TBitmap: Functions to convert between TBitmap32 an TBitmap.
  • GR32_TextUX: Drawing text in high quality on a TBitmap32 canvas.
  • GR32_VideoFilmStrip: Add a video filmstrip frame effect to a TBitmap32 with one line of code. Typically to be used for video thumbnails.
The components come with full source code and can be evaluated freely. If you like it and decide to use it in a freeware, shareware or commercial (or any other money making - advertising, in app. selling, etc.) product please buy one of the licenses.


GR32_AlphaIcon

GR32_AlphaIcon is a Delphi Graphics32 component: convert (assign) a HIcon handle or a TIcon to a TBitmap32 with full transparency support.
  • procedure Icon2Bitmap32(IconHandle: HIcon; Bitmap32: TBitmap32);
  • procedure Icon2Bitmap32(Icon: TIcon; Bitmap32: TBitmap32);
To get the 256 x 256 icon call Icon.SetSize(256, 256) before the assignment:
Uses
    GR32_AlphaIcon;

var
    Bitmap32: TBitmap32;
    Icon: TIcon;
begin
    Bitmap32 := TBitmap32.Create;
    Icon := TIcon.Create;
    try
        Icon.LoadFromFile(FileName);
        Icon.SetSize(256, 256);
        Icon2Bitmap32(Icon.Handle, Bitmap32);
      	//* Do what is needed with 'Bitmap32'
    finally
    	FreeAndNil(Icon);
    	FreeAndNil(Bitmap32);
    end;

LineHQ

Draw high quality antialiased line or lines from defined points with optional extra antialiasing with one line of code.
Note that using the antialiasing parameter higher than 1.0, actually draws the line(s) on a temporary bitmap and resamples it down using a cubic kernel resampler, then draws it onto the destination canvas. If antialiasing parameter is 1.0 the high quality line is drawn immediatelly on the destination canvas so it's much-much more faster.
Also drawing multiple lines from a point list is again much more faster than drawing lines one-by-one separatelly.
In most cases there's no need to use antialiasing above 1.0 only if a really ultra high quality graphics is needed.


GR32_BackendRelease

GR32_BackendRelease is a Delphi Graphics32 component that allows assigning a GR32 bitmap to a Windows GDI bitmap with one line of code that avoids copying the bitmap.
The bigger the bitmap is the more speed-up is achieved.
Uses
    GR32_BackendRelease;

procedure
var
    Bitmap32: TBitmap32;
    Bitmap: TBitmap;
begin
    Bitmap32 := TBitmap32.Create(TGDIReleaseBackend);
    try
        Bitmap := TBitmap.Create;
        //* Do what is needed with 'Bitmap32'
        Bitmap.Handle := (Bitmap32.Backend as TGDIReleaseBackend).ReleaseHandle;
    finally
    	FreeAndNil(Bitmap32);
    end;

GR32_MemoryBackendNoInit

GR32_MemoryBackendNoInit is a Delphi Graphics32 component: when resizing a GR32 TBitmap32 to a new size the bitmap buffer is not initialized at all.
Using this backend avoids clearing the bitmap after a resize if the bitmap buffer is overwritten completely anyway.
The bigger the bitmap is the more speed-up is achieved.
This backend is not a GDI backend, so no GDI stuff is suported, eg. no writing text.
Uses
    GR32_MemoryBackendNoInit;

procedure
var
    Bitmap32: TBitmap32;
begin
    Bitmap32 := TBitmap32.Create(TMemoryBackendNoInit);
    try
        //* Do what is needed with 'Bitmap32'
    finally
    	FreeAndNil(Bitmap32);
    end;

GR32_MemoryBackendTransparent

GR32_MemoryBackendTransparent is a Delphi Graphics32 component.
When resizing a GR32 TBitmap32 to a new size the bitmap is initialized to a transparent background. Using this backend avoids clearing the bitmap from clBlack32 by default to completely transparent.
The bigger the bitmap is the more speed-up is achieved.
This backend is not a GDI backend, so no GDI stuff is suported, eg. no writing text.
Uses
    GR32_MemoryBackendTransparent;

procedure
var
    Bitmap32: TBitmap32;
begin
    Bitmap32 := TBitmap32.Create(TMemoryBackendTransparent);
    try
        //* Do what is needed with 'Bitmap32', it is completely transparent now
    finally
    	FreeAndNil(Bitmap32);
    end;

GR32_PNGImage2Bitmap32

GR32_PNGImage2Bitmap32 is a Delphi Graphics32 component: convert a TPNGImage to a TBitmap32 and vice versa with full transparency support.
  • procedure PNGImage2Bitmap32(PNGImage: TPNGImage; Bitmap32: TBitmap32);
  • procedure Bitmap322PNGImage(Bitmap32: TBitmap32; PNGImage: TPNGImage);
  • function LoadPNGImage2Bitmap32(FileName: String; Bitmap32: TBitmap32): Boolean;

GR32_Resampler

GR32_Resampler is a Delphi Graphics32 component: resize a TBitmap32 or a TBitmap with one line of code with Graphics32's high quality resamplers.
'DontResizeSmaller': if the source bitmap is smaller than the output 'Width' and 'Height' requested the input bitmap is returned without processing.
'StrictDimensions': if the source bitmap resized is smaller than the output 'Width' or 'Height' requested the input bitmap is resized to fit and is centered in the requested dimensions with a transparent background. Useful when using a TImageList for storing the thumbnails.
  • function ResampleBitmap(InBitmap: TBitmap32; Width, Height: Integer; OutBitmap: TBitmap32; KeepAspectRatio: Boolean; DontResizeSmaller: Boolean = True; StrictDimensions: Boolean = False; GR32Resampler: Cardinal = GR32_RASAMPLER_LANCZOS; BackgroundColor: TColor32 = $00000000): Boolean; overload;
  • function ResampleBitmap(InBitmap: TBitmap32; Width, Height: Integer; OutBitmap: TBitmap; KeepAspectRatio: Boolean; DontResizeSmaller: Boolean = True; StrictDimensions: Boolean = False; GR32Resampler: Cardinal = GR32_RASAMPLER_LANCZOS; BackgroundColor: TColor32 = $00000000): Boolean; overload;
  • function ResampleBitmap(InBitmap: TBitmap; Width, Height: Integer; OutBitmap: TBitmap32; KeepAspectRatio: Boolean; DontResizeSmaller: Boolean = True; StrictDimensions: Boolean = False; GR32Resampler: Cardinal = GR32_RASAMPLER_LANCZOS; BackgroundColor: TColor32 = $00000000): Boolean; overload;
  • function ResampleBitmap(InBitmap: TBitmap; Width, Height: Integer; OutBitmap: TBitmap; KeepAspectRatio: Boolean; DontResizeSmaller: Boolean = True; StrictDimensions: Boolean = False; GR32Resampler: Cardinal = GR32_RASAMPLER_LANCZOS; BackgroundColor: TColor32 = $00000000): Boolean; overload;
  • function ResampleBitmapFast(InBitmap: TBitmap32; Width, Height: Integer; OutBitmap: TBitmap32; KeepAspectRatio: Boolean; DontResizeSmaller: Boolean = True; StrictDimensions: Boolean = False; GR32Resampler: Cardinal = GR32_RASAMPLER_LINEAR; BackgroundColor: TColor32 = $00000000): Boolean;
ResampleBitmapFast() is optimized for speed but requires that the 'InBitmap' and 'OutBitmap' must not be the same object instance as the source is directly applyed to the output.
Note that the ResampleBitmapFast() function changes the 'InBitmap''s resampler to Linear by default, specify 'GR32_RASAMPLER_NO_CHANGE' for 'GR32Resampler' if you don't wanto to change the resampler or re-set it after this call.


GR32_Shadow

GR32_Shadow is a Delphi Graphics32 component to add a shadow effect to a TBitmap32 with one line of code. Typically to be used for thumbnails.
The output bitmap is + ShadowSize larger, so provide "width/height - ShadowSize" sized input bitmaps.
For 100% UI DPI scaling ShadowSize = 2 is recommended, for 150% ShadowSize = 3 etc..
  • function AddShadow2Image(Bitmap32: TBitmap32; ShadowSize: Integer; Intensity: Byte = $AF): Boolean; overload;
  • function AddShadow2Image(Bitmap: TBitmap; ShadowSize: Integer; Intensity: Byte = $AF): Boolean; overload;
  • function AddShadow2ImageReturnBitmapHandle(Bitmap32: TBitmap32; ShadowSize: Integer; Intensity: Byte = $AF): HBitmap;
  • function AddShadow2ImageBlurred(Bitmap32: TBitmap32; DistanceX: Integer = 2; DistanceY: Integer = 2; BlurIntensity: Double = 3.0; Intensity: Byte = $B8): Boolean; overload;
  • function AddShadow2ImageBlurred(Bitmap: TBitmap; DistanceX: Integer = 2; DistanceY: Integer = 2; BlurIntensity: Double = 3.0; Intensity: Byte = $B8): Boolean; overload;
  • function AddShadow2ImageBlurredReturnBitmapHandle(Bitmap32: TBitmap32; DistanceX: Integer = 2; DistanceY: Integer = 2; BlurIntensity: Double = 3.0; Intensity: Byte = $B8): HBitmap;
  • function AddAlphaShadow2Image(Bitmap32: TBitmap32; DistanceX: Integer = 4; DistanceY: Integer = 4; Blurred: Boolean = True; BlurIntensity: Double = 2.0; Intensity: Byte = $AF; BackgroundColor: TColor32 = $00000000): TPoint; overload;
Note that using AddShadow2ImageBlurred(), the 'BlurIntensity' should not be larger then the 'DistanceX' and 'DistanceY' value (using distance 'X' and 'Y' = '2' and 'BlurIntensity' = 3.0 should work though, else the shadow effect will be clipped).

Note that AddAlphaShadow2Image() expands the input bitmap dimensions to "+ Trunc(Abs(DistanceX) + BlurIntensity * 2" and "+ Trunc(Abs(DistanceY) + BlurIntensity * 2" respectively.
The new position of the original bitmap is returned in a TPoint. Usually it will be non-zero values only if the shadow position is negative and/or blur is large.


GR32_ShellItemImageFactory

GR32_ShellItemImageFactory is a Delphi Graphics32 component: get the shell image of a file or folder to a TBitmap32 with one line of code with full transparency support.
The PIDL overload can be used to parse shell object images too.
  • function GetShellItemImageFactoryThumbnail32(AFilePath: String; Bitmap32: TBitmap32; Width: Integer = 256; Height: Integer = 256): Boolean;
  • function GetShellItemImageFactoryThumbnail32(PIDL: PItemIDList; Bitmap32: TBitmap32; Width: Integer = 256; Height: Integer = 256): Boolean;
To call these functions in threads, first call 'InitShellItemImageFactory' in the thread initialization (and 'DeInitShellItemImageFactory' respectively before the thread terminates).


GR32_TBitmap

GR32_TBitmap is a Delphi Graphics32 component: functions to convert between TBitmap32 an TBitmap.
    procedure HBitmapToBitmap32(BitmapHandle: HBitmap; Bitmap32: TBitmap32);
  • function AssignBitmapSafe(SourceBitmap: TBitmap32; DestinationBitmap: TBitmap32): Boolean;
  • function AssignBitmapSafe(SourceBitmap: TBitmap32; DestinationBitmap: TBitmap): Boolean;
  • function AssignBitmapSafe(SourceBitmap: TBitmap; DestinationBitmap: TBitmap32): Boolean;
  • function AssignBitmapSafe(SourceBitmap: TBitmap; DestinationBitmap: TBitmap): Boolean;

GR32_VideoFilmStrip

GR32_VideoFilmStrip is a Delphi Graphics32 component to add a filmstrip around the bitmap (video frame images) effect to a TBitmap32 with one line of code. Typically to be used for video thumbnails.
The film frame bitmaps can be easily customized with either replacing the 2 PNG files in the resource ('FilmThumbnails.res') or loading custom PNG bitmaps into the global 'FilmFrameLeft' and 'FilmFrameRight' objects by code.
Non 1:1 aspect ratio video images are supported, use the 'MediaWidth' and 'MediaHeight' parameters from the actual video parameters, value of '0' uses the 'Picture''s dimensions (1:1 ratio).
'StrictDimensions': if the result bitmap is smaller than the output 'Width' or 'Height' requested, the input bitmap is centered in the requested dimensions with a transparent background.
Useful when using a TImageList for storing the thumbnails.
  • function DrawVideoFilmStrip(Picture: TBitmap32; DestinationBitmap: TBitmap32; ThumbnailWidth, ThumbnailHeight: Integer; MediaWidth: Integer = 0; MediaHeight: Integer = 0; StrictDimensions: Boolean = False; GR32Resampler: Cardinal = GR32_RASAMPLER_LANCZOS): Boolean;
  • function DrawVideoFilmStrip(Picture: TBitmap; DestinationBitmap: TBitmap; ThumbnailWidth, ThumbnailHeight: Integer; MediaWidth: Integer = 0; MediaHeight: Integer = 0; StrictDimensions: Boolean = False; GR32Resampler: Cardinal = GR32_RASAMPLER_LANCZOS): Boolean;
Note that the function automatically resizes the input picture to the requested dimensions with a high quality Lanczos resampler by default, so no need to resize the bitmap before this function as eg. ResampleBitmap() is actually much slower.
DrawVideoFilmStrip() draws the input picture directly on to the 'DestinationBitmap', ResampleBitmap() uses an intermediate temporary bitmap buffer so is slower.
Note that the DrawVideoFilmStrip() function changes the 'Picture''s resampler to Lanczos by default, specify 'GR32_RASAMPLER_NO_CHANGE' for 'GR32Resampler' if you don't wanto to change the resampler or re-set it after this call.

Tip: use AddAlphaShadow2Image() with 'DistanceX = 2' and 'DistanceY = 2' to add a nice shadow effect to this thumbnail.




[Top]